package com.zj.recyclerviewdemo.mvp;

import android.graphics.RadialGradient;

import com.zj.recyclerviewdemo.R;
import com.zj.recyclerviewdemo.bean.Item;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.StringTokenizer;

/**
 * Created by Lenovo on 2017/4/26.
 */

public class MainPresenter implements MainContract.Presenter {

    private MainContract.View view;

    public MainPresenter(MainContract.View view) {
        this.view = view;
        view.setPresenter(this);
        view.initViews();
    }

    @Override
    public void getData() {
        int NUM = 20;
        List<Item> itemList = new ArrayList<>();

        for (int i = 0; i < NUM; i++) {
            itemList.add(new Item(String.valueOf(i), R.mipmap.ic_launcher));
        }

        view.showData(itemList);
    }

    @Override
    public void getRefreshData() {
        int NUM = 20;
        List<Item> itemList = new ArrayList<>();

        Random random = new Random();
        for (int i = 0; i < NUM; i++) {
            itemList.add(new Item(String.valueOf(i + random.nextInt(NUM)), R.mipmap.ic_launcher_round));
        }

        view.showRefreshData(itemList);
    }

    @Override
    public void getPullUpRefreshData() {
        int NUM = 20;
        List<Item> itemList = new ArrayList<>();

        Random random = new Random();
        for (int i = 0; i < NUM; i++) {
            itemList.add(new Item("new" + String.valueOf(random.nextInt(100)), R.mipmap.ic_launcher));
        }

        view.addRefreshData(itemList);
    }
}
